home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / shells / cshel510 / part01 next >
Internet Message Format  |  1991-04-16  |  65KB

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i088: CShell 5.10 - alternative command interface, Part01/06
  4. Reply-To: umueller@iiic.ethz.ch
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v91i088@ab20.larc.nasa.gov>
  7. Date: 16 Apr 91 19:34:37 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga.misc
  11.  
  12. Submitted-by: umueller@iiic.ethz.ch
  13. Posting-number: Volume 91, Issue 088
  14. Archive-name: shells/cshell-5.10/part01
  15.  
  16. [ executable to appear in comp.binaries.amiga  ...tad ]
  17. [ file `csh.doc' was split to facilitate posting  ...tad ]
  18.  
  19. Announcing: CShell 5.10
  20.  
  21. CShell  5.10  offers  a much more powerful parser, some new command options
  22. and bug fixes.
  23.  
  24. Main features include: (see changes.doc for complete list)
  25. - totally rewritten parser, therefore:
  26. -  local variables, in aliases as well as in batch files
  27. -  blocks can be formed, redirected, aborted: {e yo;e ho}
  28. -  $(foo) will insert output of program foo at that point, similar: `foo`
  29. -  parsing also done with command itself, e.g. '*' is a legal command line
  30. -  aliases/foreach/forline/fornum/source can be redirected as a whole
  31. -  direct recursion in aliases prevented, 'alias ls "ls -s"' works
  32. -  additional speedup; twice as fast as 4.xx, four times as fast as c:Execute
  33. - 'assign' now can handle all types of assings correctly under 2.0
  34. - 'class' can pattern-match now, e.g. 'class sound name="mod.*"'
  35. - 'copy' has a larger buffer, copy -m' moves files
  36. - 'dir -z formatstring' is a very powerful formatting feature, some more opts
  37. - 'forline i STDIN' reads args from stdin
  38. - 'man' can handle multiple .doc files, so you can document your own aliases
  39. - 'source' can handle multiple line blocks of arbitrary length
  40. - 'rback'/'run' now set the variable '$_newproc' to the # of the new process
  41. - $_abbrev can be used to disable abbreviation if internal commands
  42. - $_ioerr contains the secondary return code after an error
  43. - $_pipe now holds the directory for the temporary pipe files
  44. - $_verbose need to be set to special values, now can trace alias calls
  45. - @console tells whether stdin or stdout are interactive
  46. - @ioerr converts a secondary error number to a string (like 'Why')
  47. - @mounted indicates whether a device has been mounted yet or not
  48. - @sortnum sorts its arguments numerically
  49. - shift-arrow-up and shift-arrow-down now behave like under AmigaDOS
  50. - concatted lines in source files can be arbitrary long
  51. - . now stands for current directory, .. for parent
  52.  
  53. Most important bug fixes:
  54. - INTERNAL residents can now be used with V37 Kickstarts
  55. - c:Execute can be started
  56. - 'Wait 5&' as an alias for 'rback Wait 5' now works
  57.  
  58. Miscellaneous info:
  59. - Some more documentation, tips & tricks
  60. - Executable size: 89K
  61.  
  62.  
  63. #!/bin/sh
  64. # This is a shell archive.  Remove anything before this line, then unpack
  65. # it by saving it into a file and typing "sh file".  To overwrite existing
  66. # files, type "sh file -c".  You can also feed this as standard input via
  67. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  68. # will see the following message at the end:
  69. #        "End of archive 1 (of 6)."
  70. # Contents:  README Syms.c class.sh globals.c lmakefile main.c makefile
  71. #   menu.sh proto.h run.c sample.sh set.c shell.h technotes.doc
  72. #   tips.doc
  73. # Wrapped by tadguy@ab20 on Tue Apr 16 15:34:34 1991
  74. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  75. if test -f 'README' -a "${1}" != "-c" ; then 
  76.   echo shar: Will not clobber existing file \"'README'\"
  77. else
  78. echo shar: Extracting \"'README'\" \(2637 characters\)
  79. sed "s/^X//" >'README' <<'END_OF_FILE'
  80. XAnnouncing: CShell 5.10
  81. X
  82. XCShell  5.10  offers  a much more powerful parser, some new command options
  83. Xand bug fixes.
  84. X
  85. XMain features include: (see changes.doc for complete list)
  86. X- totally rewritten parser, therefore:
  87. X-  local variables, in aliases as well as in batch files
  88. X-  blocks can be formed, redirected, aborted: {e yo;e ho}
  89. X-  $(foo) will insert output of program foo at that point, similar: `foo`
  90. X-  parsing also done with command itself, e.g. '*' is a legal command line
  91. X-  aliases/foreach/forline/fornum/source can be redirected as a whole
  92. X-  direct recursion in aliases prevented, 'alias ls "ls -s"' works
  93. X-  additional speedup; twice as fast as 4.xx, four times as fast as c:Execute
  94. X- 'assign' now can handle all types of assings correctly under 2.0
  95. X- 'class' can pattern-match now, e.g. 'class sound name="mod.*"'
  96. X- 'copy' has a larger buffer, copy -m' moves files
  97. X- 'dir -z formatstring' is a very powerful formatting feature, some more opts
  98. X- 'forline i STDIN' reads args from stdin
  99. X- 'man' can handle multiple .doc files, so you can document your own aliases
  100. X- 'source' can handle multiple line blocks of arbitrary length
  101. X- 'rback'/'run' now set the variable '$_newproc' to the # of the new process
  102. X- $_abbrev can be used to disable abbreviation if internal commands
  103. X- $_ioerr contains the secondary return code after an error
  104. X- $_pipe now holds the directory for the temporary pipe files
  105. X- $_verbose need to be set to special values, now can trace alias calls
  106. X- @console tells whether stdin or stdout are interactive
  107. X- @ioerr converts a secondary error number to a string (like 'Why')
  108. X- @mounted indicates whether a device has been mounted yet or not
  109. X- @sortnum sorts its arguments numerically
  110. X- shift-arrow-up and shift-arrow-down now behave like under AmigaDOS
  111. X- concatted lines in source files can be arbitrary long
  112. X- . now stands for current directory, .. for parent
  113. X
  114. XMost important bug fixes:
  115. X- INTERNAL residents can now be used with V37 Kickstarts
  116. X- c:Execute can be started
  117. X- 'Wait 5&' as an alias for 'rback Wait 5' now works
  118. X
  119. XMiscellaneous info:
  120. X- Some more documentation, tips & tricks
  121. X- Executable size: 89K
  122. X
  123. XAvailable now from ab20.larc.nasa.gov, will be distributed over
  124. Xcomp.binaries.amiga.
  125. X
  126. Xcsh510.lzh      # executable, docs, sample scripts
  127. Xcsh510s.lzh     # source (lattice & manx)
  128. X                                          __
  129. X |          Urban Mueller         |      / / |    Urban Mueller    |
  130. X | USENET:  umueller@iiic.ethz.ch | __  / /  |    Schulhausstr. 83 |
  131. X | FIDONET: 2:302/906 (AUGL)      | \ \/ /   | CH-6312 Steinhausen |
  132. X | "Don't tell my employer"       |  \__/    |    SWITZERLAND      |
  133. END_OF_FILE
  134. if test 2637 -ne `wc -c <'README'`; then
  135.     echo shar: \"'README'\" unpacked with wrong size!
  136. fi
  137. # end of 'README'
  138. fi
  139. if test -f 'Syms.c' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'Syms.c'\"
  141. else
  142. echo shar: Extracting \"'Syms.c'\" \(19 characters\)
  143. sed "s/^X//" >'Syms.c' <<'END_OF_FILE'
  144. X#include "shell.h"
  145. END_OF_FILE
  146. if test 19 -ne `wc -c <'Syms.c'`; then
  147.     echo shar: \"'Syms.c'\" unpacked with wrong size!
  148. fi
  149. # end of 'Syms.c'
  150. fi
  151. if test -f 'class.sh' -a "${1}" != "-c" ; then 
  152.   echo shar: Will not clobber existing file \"'class.sh'\"
  153. else
  154. echo shar: Extracting \"'class.sh'\" \(1730 characters\)
  155. sed "s/^X//" >'class.sh' <<'END_OF_FILE'
  156. Xclass -n
  157. Xclass dms      offs=0,444D5321
  158. Xclass warp     offs=0,57617270
  159. Xclass zoom     offs=0,5A4F4F4D
  160. Xclass lharc    offs=2,2D6C68..2D
  161. Xclass zoo      offs=0,5A4F4F20
  162. Xclass arc      offs=0,1a08
  163. Xclass compr    offs=0,1f9d
  164. Xclass anim     offs=0,464f524d........414e494d
  165. Xclass icon     offs=0,e3100001 offs=0,f34c0012
  166. Xclass gif      offs=0,474946
  167. Xclass zip      offs=0,504b0304
  168. Xclass ppacked  offs=0,50503230
  169. X
  170. Xclass dms      suff=.dms act exec="Dms write" extr="Dms write" view="Dms view"
  171. Xclass warp     suff=.wrp act exec="Warp write 0 79" extr="Warp write 0 79"
  172. Xclass zoom     suff=.zom act exec="Zoom" extr="Zoom"
  173. Xclass lharc    suff=.lzh act exec="lharc e" extr="lharc e" view="lharc v" add="lharc a" edit=lharca
  174. Xclass zoo      suff=.zoo act exec="zoo e" extr="zoo e//" view="zoo v" add="zoo a"
  175. Xclass arc      suff=.arc act exec="arc e" extr="arc e" view="arc -v"
  176. Xclass zip      suff=.zip act exec="unzip" extr="unzip" view="unzip l"
  177. Xclass ppacked  suff=.pp  act exec="ppmore" view=ppmore
  178. Xclass lhwarp   suff=.lhw act exec="lhwarp write 0"
  179. Xclass anim     suff=.anim act exec=showanim view=showanim
  180. Xclass gif      suff=.gif  act exec=virtgif  view=virtgif extr="shamsharp"
  181. Xclass ilbm     offs=0,464F524D........494C424D act exec=M view=M edit=dpaint
  182. Xclass text     offs=0,464F524D........46545854 act edit=excellence
  183. Xclass prog     offs=0,000003f300000000 act view=htype edit=newzap
  184. Xclass object   suff=.o
  185. Xclass include  suff=.h
  186. Xclass c_source suff=.c act exec=ced
  187. Xclass script   suff=.sh
  188. Xclass ascii    suff=.doc suff=.txt name=readme chars act view=more exec=more edit=ced
  189. Xclass ""       default act view=htype edit=ced
  190. X
  191. Xalias v    "%n action -a view $n;more $n"
  192. Xalias ed   "%n action -a edit $n;ced $n"
  193. Xalias xt   "action extr"
  194. END_OF_FILE
  195. if test 1730 -ne `wc -c <'class.sh'`; then
  196.     echo shar: \"'class.sh'\" unpacked with wrong size!
  197. fi
  198. # end of 'class.sh'
  199. fi
  200. if test -f 'globals.c' -a "${1}" != "-c" ; then 
  201.   echo shar: Will not clobber existing file \"'globals.c'\"
  202. else
  203. echo shar: Extracting \"'globals.c'\" \(4788 characters\)
  204. sed "s/^X//" >'globals.c' <<'END_OF_FILE'
  205. X
  206. X/*
  207. X * GLOBALS.C
  208. X *
  209. X * (c)1986 Matthew Dillon     9 October 1986
  210. X *
  211. X *    Most global variables.
  212. X *
  213. X * Version 2.07M by Steve Drew 10-Sep-87
  214. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  215. X * Version 5.00L by Urban Mueller 17-Feb-91
  216. X *
  217. X */
  218. X
  219. X#include "shell.h"
  220. X
  221. Xchar v_titlebar    []="_titlebar";    /* Window title                        */
  222. Xchar v_prompt    []="_prompt";    /* your prompt (ascii command)        */
  223. Xchar v_hist        []="_history";    /* set history depth (value)        */
  224. Xchar v_histnum    []="_histnum";    /* set history numbering var        */
  225. Xchar v_debug    []="_debug";    /* set debug mode                    */
  226. Xchar v_verbose    []="_verbose";    /* set verbose for source files        */
  227. Xchar v_stat        []="_maxerr";    /* worst return value to date        */
  228. Xchar v_lasterr    []="_lasterr";    /* return value from last comm.        */
  229. Xchar v_cwd        []="_cwd";        /* current directory                */
  230. Xchar v_except    []="_except";    /* "nnn;command"                    */
  231. Xchar v_every    []="_every";    /* executed before prompt            */
  232. Xchar v_passed    []="_passed";    /* passed arguments to source file    */
  233. Xchar v_path        []="_path";        /* search path for external commands*/
  234. Xchar v_gotofwd    []="_gtf";        /* set name for fwd goto name        */
  235. Xchar v_linenum    []="_linenum";    /* name for forline line #            */
  236. Xchar v_lcd        []="_lcd";        /* last current directory            */
  237. Xchar v_rxpath    []="_rxpath";    /* path for .rexx commands            */
  238. Xchar v_hilite    []="_hilite";    /* hilighting escape sequence        */
  239. Xchar v_scroll    []="_scroll";    /* scroll jump in fast mode            */
  240. Xchar v_minrows    []="_minrows";    /* minimum # of rows for fast scroll*/
  241. Xchar v_result    []="_result";    /* result from rxsend                */
  242. Xchar v_qcd        []="_qcd";        /* file name for csh-qcd            */
  243. Xchar v_noreq    []="_noreq";    /* turn off system requesters        */
  244. Xchar v_value    []="_value";    /* return value of a function        */
  245. Xchar v_nobreak    []="_nobreak";    /* disabling of ^C                    */
  246. Xchar v_bground    []="_bground";    /* started in background            */
  247. Xchar v_pipe        []="_pipe";        /* path for pipes                    */
  248. Xchar v_datefmt    []="_datefmt";    /* format of dates                    */
  249. Xchar v_ioerr    []="_ioerr";    /* last secondary result            */
  250. Xchar v_abbrev    []="_abbrev";    /* disable command abbreviations    */
  251. X
  252. Xstruct HIST *H_head, *H_tail;    /* HISTORY lists */
  253. X
  254. Xstruct PERROR Perror[]= {    /* error code->string */
  255. X    103,    "Insufficient free storage",
  256. X    105,    "Task table full",
  257. X    120,    "Argument line invalid or too long",
  258. X    121,    "File is not an object module",
  259. X    122,    "Invalid resident library during load",
  260. X    201,    "No default directory",
  261. X    202,    "Object in use",
  262. X    203,    "Object already exists",
  263. X    204,    "Directory not found",
  264. X    205,    "Object not found",
  265. X    206,    "Bad stream name",
  266. X    207,    "Object too large",
  267. X    209,    "Action not known",
  268. X    210,    "Invalid stream component name",
  269. X    211,    "Invalid object lock",
  270. X    212,    "Object not of required type",
  271. X    213,    "Disk not validated",
  272. X    214,    "Disk write protected",
  273. X    215,    "Rename across devices",
  274. X    216,    "Directory not empty",
  275. X    217,    "Too many levels",
  276. X    218,    "Device not mounted",
  277. X    219,    "Seek error",
  278. X    220,    "Comment too long",
  279. X    221,    "Disk full",
  280. X    222,    "File delete protected",
  281. X    223,    "File write protected",
  282. X    224,    "File read protected",
  283. X    225,    "Not a DOS disk",
  284. X    226,    "No disk in drive",
  285. X
  286. X /* custom error messages */
  287. X
  288. X    500,    "Bad arguments",
  289. X    501,    "Label not found",
  290. X    502,    "Must be within source file",
  291. X    503,    "Syntax Error",
  292. X    504,    "Redirection error",
  293. X    505,    "Pipe error",
  294. X    506,    "Too many arguments",
  295. X    507,    "Destination not a directory",
  296. X    508,    "Cannot mv a filesystem",
  297. X    509,    "Error in command name",
  298. X    510,    "Bad drive name",
  299. X    511,    "Illegal number",
  300. X    512,    "Out of memory",
  301. X    513,    "User interrupt",
  302. X    0,    NULL
  303. X};
  304. X
  305. Xchar **av;                    /* Internal argument list                */
  306. XFILE *Src_base[MAXSRC];        /* file pointers for source files        */
  307. Xlong  Src_pos[MAXSRC];        /* seek position storage for same        */
  308. Xshort Src_if[MAXSRC];        /* the if level at batch file start        */
  309. Xshort Src_abort[MAXSRC];    /* abort this batch file                */
  310. Xchar If_base[MAXIF];        /* If/Else stack for conditionals        */
  311. Xint H_len, H_tail_base;        /* History associated stuff                */
  312. Xint H_stack;                /* AddHistory disable stack                */
  313. Xint E_stack;                /* Exception disable stack                */
  314. Xint Src_stack, If_stack;    /* Stack Indexes                        */
  315. Xint forward_goto;            /* Flag for searching for foward lables    */
  316. Xint ac;                        /* Internal argc                        */
  317. Xint max_ac=256;                /* Maximum # of args (increasable)        */
  318. Xint debug;                    /* Debug mode                            */
  319. Xint disable;                /* Disable com. execution (conditionals)*/
  320. Xint Verbose;                /* Verbose mode for source files        */
  321. Xint Lastresult;                /* Last return code                        */
  322. Xint Exec_abortline;            /* flag to abort rest of line            */
  323. Xint Quit;                    /* Quit flag                            */
  324. Xchar stdin_redir;            /* stdin is redirected                    */
  325. Xchar stdout_redir;            /* stdout is redirected                    */
  326. Xchar *MyMem;
  327. Xstruct Process *Myprocess;
  328. Xstruct CommandLineInterface *Mycli;
  329. Xint S_histlen = 20;            /* Max # history entries                */
  330. X
  331. Xunsigned int options;
  332. Xchar Buf[280], confirmed;
  333. XCLASS *CRoot, *LastCRoot;
  334. X
  335. Xlong IoError;
  336. END_OF_FILE
  337. if test 4788 -ne `wc -c <'globals.c'`; then
  338.     echo shar: \"'globals.c'\" unpacked with wrong size!
  339. fi
  340. # end of 'globals.c'
  341. fi
  342. if test -f 'lmakefile' -a "${1}" != "-c" ; then 
  343.   echo shar: Will not clobber existing file \"'lmakefile'\"
  344. else
  345. echo shar: Extracting \"'lmakefile'\" \(817 characters\)
  346. sed "s/^X//" >'lmakefile' <<'END_OF_FILE'
  347. X######################################################################
  348. X# Makefile to build Shell 5.10L under Lattice C 5.10
  349. X# NOTE: char's are UNSIGNED by default, and the executable's calld 'zsh'
  350. X
  351. XFLAGS  = -ms -v -d3 -cu -cs -rr -O
  352. XOBJ=run.o main.o comm1.o comm2.o comm3.o execom.o set.o sub.o globals.o rawcon.o
  353. X
  354. X# -ms = short code optimize     -v  = no stack overflow check
  355. X# -d0 = no debug info           -cu = unsigned chars by default
  356. X# -cs = one copy per string     -m3 = code for 68030
  357. X# -H  = read precompiled header -ph = write precompiled header
  358. X# -rr = register arguments       ND = strip debug information
  359. X
  360. Xzsh: $(OBJ)
  361. X    BLINK lib:cres.o $(OBJ) LIB lib:lcr.lib lib:amiga.lib TO zsh NOICONS ND
  362. X
  363. Xshell.syms: shell.h proto.h
  364. X    lc -cu -ph -oshell.syms syms.c
  365. X
  366. X$(OBJ): shell.syms
  367. X    lc $(FLAGS) -HShell.syms $*.c
  368. END_OF_FILE
  369. if test 817 -ne `wc -c <'lmakefile'`; then
  370.     echo shar: \"'lmakefile'\" unpacked with wrong size!
  371. fi
  372. # end of 'lmakefile'
  373. fi
  374. if test -f 'main.c' -a "${1}" != "-c" ; then 
  375.   echo shar: Will not clobber existing file \"'main.c'\"
  376. else
  377. echo shar: Extracting \"'main.c'\" \(8629 characters\)
  378. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  379. X/*
  380. X * MAIN.C
  381. X *
  382. X * Matthew Dillon, 24 Feb 1986
  383. X * (c)1986 Matthew Dillon     9 October 1986
  384. X *
  385. X * Version 2.07M by Steve Drew 10-Sep-87
  386. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  387. X * Version 5.00L by Urban Mueller 17-Feb-91
  388. X *
  389. X */
  390. X
  391. X#include "shell.h"
  392. X
  393. Xvoid breakreset(void);
  394. Xstruct Window *getwindow (void);
  395. Xstruct RootNode2x *RootNode;
  396. X
  397. Xchar shellname[]   ="CShell V5.10L";
  398. Xchar shellversion[]="510";
  399. Xchar shellvers[]   ="5.10";
  400. Xchar shellv   []   ="\0$VER: csh 5.1";
  401. Xchar shellctr []   ="CshCounter";
  402. Xchar shellres []   ="CshResident";
  403. X
  404. Xstatic void add_residents(void);
  405. X
  406. Xchar *oldtitle;
  407. Xchar trueprompt[100];
  408. Xchar Inline[260];
  409. Xstruct IntuitionBase *IntuitionBase;
  410. Xstruct Window *Win;
  411. Xstruct ArpBase *ArpBase;
  412. Xint    oldtaskpri=-999;
  413. X
  414. Xextern struct DosLibrary *DOSBase;
  415. X
  416. Xstatic char *defset[]={
  417. X    v_histnum,  "0",
  418. X    v_titlebar, shellname,
  419. X    v_hist,     "50",
  420. X    v_lasterr,  "0",
  421. X    v_stat,     "0",
  422. X    v_path,     "RAM:,RAM:c,df0:c,df1:c,sys:system,csh:,s:",
  423. X    v_rxpath,   "REXX:",
  424. X    v_scroll,   "3",
  425. X    v_minrows,  "34",
  426. X    v_hilite,   "c7",
  427. X    v_lcd,      "",
  428. X    v_qcd,      "csh:csh-qcd",
  429. X    "_terminal","",
  430. X    "_man",     "csh:csh.doc",
  431. X    "_insert",  "1",
  432. X    "_version", shellversion,
  433. X    NULL,       NULL
  434. X};
  435. X
  436. Xstatic char *defalias[]={
  437. X    "cls",  "echo -n ^l",
  438. X    "dswap","cd $_lcd",
  439. X    "exit", "endcli;quit",
  440. X    "cdir", "%q cd $q; cls; dir",
  441. X    "q",    "quit",
  442. X    "manlist", "sea -nl $_man \"    \"",
  443. X    NULL,   NULL
  444. X};
  445. X
  446. Xextern struct Library *DosBase;
  447. X
  448. X
  449. Xmain(argc, argv)
  450. Xchar *argv[];
  451. X{
  452. X    static ROOT locals;
  453. X    int i;
  454. X    char buf[10];
  455. X    struct Window *getwindow();
  456. X    char nologin=0;
  457. X#ifdef AZTEC_C
  458. X    extern int Enable_Abort;
  459. X    Enable_Abort = 0;
  460. X#endif
  461. X
  462. X    MyMem=salloc(4);
  463. X
  464. X    if( argc==0 ) {              /* Prevent starting from workbench */
  465. X        Delay(120);
  466. X        exit(0);
  467. X    }
  468. X
  469. X    RootNode=(void *)DOSBase->dl_Root;
  470. X    push_locals( &locals );
  471. X
  472. X    initmap();
  473. X    init_mbase();
  474. X
  475. X    if(!(ArpBase=(struct ArpBase *)OpenLibrary("arp.library",34L)))
  476. X        { printf("No arp library\n"); exit(0); }
  477. X
  478. X    IntuitionBase=(struct IntuitionBase *)ArpBase->IntuiBase;
  479. X
  480. X    if( ArpBase->DosBase->lib_Version >= 36 )
  481. X        o_kick20=1;
  482. X    set_var( LEVEL_SET, "_kick2x", (o_kick20) ? "1" : "0" );
  483. X
  484. X    if( !IsInteractive(Input()))
  485. X        o_bground=1;
  486. X    set_var( LEVEL_SET, v_bground, (o_bground) ? "1" : "0" );
  487. X
  488. X
  489. X    Forbid();
  490. X    i=0;
  491. X    if (Getenv(shellctr,buf,10L)) i=atoi(buf);
  492. X    if (Getenv(shellres,buf,10L)) o_resident=1;
  493. X    sprintf(buf, "%d", i+1);
  494. X    Setenv(shellctr, buf);
  495. X    Permit();
  496. X
  497. X#ifdef isalphanum
  498. X    for( i='a'; i<='z'; i++ )
  499. X        isalph[i]=1;
  500. X    for( i='A'; i<='Z'; i++ )
  501. X        isalph[i]=1;
  502. X    for( i='0'; i<='9'; i++ )
  503. X        isalph[i]=1;
  504. X    isalph['_']=1;
  505. X#endif
  506. X
  507. X#ifdef AZTEC_C
  508. X    stdin->_flags    |= _IONBF;    /* make sure we're set as an unbuffered tty */
  509. X    stdout->_flags    |= _IONBF;    /* in case of redirection in .login */
  510. X    Close( (BPTR)_devtab[2].fd);
  511. X    _devtab[2].mode |= O_STDIO;
  512. X    _devtab[2].fd = _devtab[1].fd;    /* set stderr to Output() otherwise */
  513. X                    /* don't work with aux driver */
  514. X#else
  515. X    /* if( setvbuf( stdout,NULL,_IOLBF,BUFSIZ )) exit(20); */
  516. X    /* setnbf( stdout ); */
  517. X    /* Close( _ufbs[2] ); */
  518. X    /*_ufbs[2]=_ufbs[1]; */
  519. X    /* setnbf( stderr ); */
  520. X#endif
  521. X
  522. X    Myprocess = (struct Process *)FindTask(0L);
  523. X    Mycli=(struct CommandLineInterface *)((long)Myprocess->pr_CLI << 2);
  524. X
  525. X    if( !o_nowindow && (Win=getwindow()) && IsInteractive(Input())) {
  526. X        oldtitle=(char *)(Win->Title);
  527. X        set_menu();
  528. X    }
  529. X
  530. X    sprintf(buf,"%ld",Myprocess->pr_TaskNum);
  531. X    set_var(LEVEL_SET, "_clinumber", buf);
  532. X
  533. X    seterr(0);
  534. X    if (Myprocess->pr_CurrentDir == NULL)
  535. X        do_cd("x :");
  536. X    else
  537. X        do_pwd(NULL);
  538. X
  539. X    o_nowindow= 1;
  540. X
  541. X    set_var(LEVEL_SET,v_prompt, (IsInteractive(Input())) ? "%c%p> ":"");
  542. X    for( i=0; defset[i]; i+=2 )
  543. X        set_var( LEVEL_SET, defset[i], defset[i+1] );
  544. X    for( i=0; defalias[i]; i+=2 )
  545. X        set_var( LEVEL_ALIAS, defalias[i], defalias[i+1] );
  546. X
  547. X    o_nowindow= 0;
  548. X    o_internal= 1;
  549. X
  550. X    for (i = 1; i < argc; ++i) {
  551. X        if (*argv[i]=='-') {
  552. X            char *str=argv[i]+1;
  553. X            for( ; *str; str++ ) {
  554. X                switch( *str) {
  555. X                case 'k': set_var(LEVEL_SET,v_nobreak,"1"); break;
  556. X                case 'i': if( str[1]=='0' ) str++, o_internal=0; break;
  557. X                case 'r': add_residents(); break;
  558. X                case 'v': Verbose=1; set_var(LEVEL_SET,v_verbose,"hs"); break;
  559. X                case 'n': nologin=TRUE;    break;
  560. X                case 'b': oldtaskpri=Myprocess->pr_Task.tc_Node.ln_Pri;
  561. X                          SetTaskPri( &Myprocess->pr_Task, -1 ); break;
  562. X                case 'f': oldtaskpri=Myprocess->pr_Task.tc_Node.ln_Pri;
  563. X                          SetTaskPri( &Myprocess->pr_Task,  1 ); break;
  564. X                case 'c': Inline[0] = ' '; Inline[1] = '\0';
  565. X                          while (++i < argc)
  566. X                              { strcat(Inline,argv[i]); strcat(Inline," "); }
  567. X                          execute(Inline);
  568. X                          main_exit(Lastresult); break;
  569. X                case 'a': o_nowindow= o_noraw= 1; 
  570. X                          set_var( LEVEL_SET, v_hilite, "" ); break;
  571. X                case 't': o_nowindow= o_vt100= o_nofastscr= 1;
  572. X                          set_var( LEVEL_SET, v_hilite, "r" );
  573. X                          set_var( LEVEL_SET, v_noreq, "1" );
  574. X                          set_var( LEVEL_SET, "_terminal", "1" );
  575. X                          set_var( LEVEL_ALIAS, "cls", "e -n ^[[0\\;0H^[[J" );
  576. X                          break;
  577. X                case 's': if( o_kick20 ) {
  578. X                              struct RootNode2x *root=(void *)DOSBase->dl_Root;
  579. X                              root->rn_Flags|=1<<24;
  580. X                          } break;
  581. X                }
  582. X            }
  583. X        } else {
  584. X            sprintf (Inline, "source %s",argv[i]);
  585. X            execute (Inline);
  586. X        }
  587. X    }
  588. X
  589. X    if (!nologin && exists("S:.login")) execute("source S:.login");
  590. X
  591. X    for (;;) {
  592. X        if (breakcheck())
  593. X#ifdef AZTEC_C
  594. X        while (WaitForChar(Input(), 100L) || stdin->_bp < stdin->_bend)
  595. X#else
  596. X        while (WaitForChar(Input(), 100L) || stdin->_rcnt != stdin->_wcnt )
  597. X#endif
  598. X            gets(Inline);
  599. X        clearerr(stdin);  /* prevent acidental quit */
  600. X        exec_every();
  601. X        update_sys_var(v_titlebar);
  602. X        update_sys_var(v_prompt);
  603. X        breakreset();
  604. X#if RAW_CONSOLE
  605. X        if (Quit || !rawgets(Inline, disable ? "_ " : trueprompt)) main_exit(0);
  606. X#else
  607. X        printf("%s", disable ? "_ " : trueprompt);
  608. X        fflush(stdout);
  609. X        if (Quit || !gets(Inline)) main_exit(0);
  610. X#endif
  611. X        breakreset();
  612. X        if (*Inline) exec_command(Inline);
  613. X    }
  614. X}
  615. X
  616. Xvoid
  617. Xmain_exit(n)
  618. X{
  619. X    int i;
  620. X    char buf[10];
  621. X
  622. X    Getenv(shellctr,buf,10L);
  623. X    i=atoi(buf);
  624. X    sprintf(buf,"%d",i-1);
  625. X    Setenv(shellctr, buf);
  626. X    if( oldtitle )
  627. X        SetWindowTitles(Win,oldtitle,(char *)-1);
  628. X    if( oldtaskpri != -999 )
  629. X        SetTaskPri(&Myprocess->pr_Task,oldtaskpri);
  630. X    for (i=1; i<MAXMYFILES; i++) myclose(i);
  631. X    remove_menu();
  632. X    CloseLibrary((struct Library *)ArpBase);
  633. X    exit(n);
  634. X}
  635. X
  636. Xint
  637. Xbreakcheck()
  638. X{
  639. X    return !o_nobreak && SetSignal(0L,0L) & SIGBREAKF_CTRL_C;
  640. X}
  641. X
  642. Xvoid
  643. Xbreakreset()
  644. X{
  645. X    SetSignal(0L, SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D);
  646. X}
  647. X
  648. Xdobreak()
  649. X{
  650. X    if (breakcheck()) { printf("^C\n"); return(1); }
  651. X    return(0);
  652. X}
  653. X
  654. X/* this routine causes manx to use this Chk_Abort() rather than it's own */
  655. X/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */
  656. X/* is zero).  Since we want to check for our own ^C's             */
  657. X
  658. Xlong
  659. XChk_Abort()
  660. X{
  661. X    return(0);
  662. X}
  663. X
  664. Xvoid
  665. X_wb_parse()
  666. X{
  667. X}
  668. X
  669. Xdo_howmany()
  670. X{
  671. X    char buf[10];
  672. X
  673. X    Getenv(shellctr, buf, 10L);
  674. X    printf("Shell(s) running: %s\n",buf);
  675. X    return 0;
  676. X}
  677. X
  678. Xstatic struct Window *
  679. Xgetwindow()
  680. X{
  681. X    struct InfoData *infodata;
  682. X    struct Window *win;
  683. X    long args[8];
  684. X
  685. X    if( o_nowindow )
  686. X        return NULL;
  687. X    infodata=(void *)SAllocMem((long)sizeof(struct InfoData),MEMF_CLEAR|MEMF_PUBLIC);
  688. X    args[0]=(long)infodata >> 2;
  689. X    Write(Output(),"",1);     /*    make window appear */ 
  690. X    SendPacket(ACTION_DISK_INFO,args,(void *)Myprocess->pr_ConsoleTask);
  691. X    win=(struct Window *)infodata->id_VolumeNode;
  692. X    FreeMem(infodata,(long)sizeof(struct InfoData));
  693. X    if( win==NULL )
  694. X        o_nowindow=1;
  695. X    newwidth();
  696. X    return win;
  697. X}
  698. X
  699. X
  700. Xextern struct DosLibrary *DOSBase;
  701. X
  702. Xstruct ResidentList {
  703. X    BPTR rl_Next;
  704. X    LONG rl_UseCount;
  705. X    BPTR rl_SegList;
  706. X    char rl_SegName[1];
  707. X};
  708. X
  709. X
  710. Xstatic void
  711. Xadd_residents()
  712. X{
  713. X    char buf[80], *g, *p, c;
  714. X    struct RootNode *Node;
  715. X    struct DosInfo  *Info;
  716. X    struct ResidentList *res;
  717. X    struct ResidentProgramNode *rpn;
  718. X
  719. X    if( o_kick20 || ArpBase->ResidentPrgList )
  720. X        return;
  721. X
  722. X    Forbid(); 
  723. X    Node=(struct RootNode *)DOSBase->dl_Root;
  724. X    Info=(struct DosInfo  *)(Node->rn_Info*4);
  725. X    res=(struct ResidentList *)((long)Info->di_NetHand*4);
  726. X
  727. X    for( ; res; res=(struct ResidentList *)((long)res->rl_Next*4) ) {
  728. X        g=res->rl_SegName, p=buf;
  729. X        for( c=*g++; c>0; --c ) *p++=*g++;
  730. X        *p=0;
  731. X        if( res->rl_UseCount>=0 )
  732. X            res->rl_UseCount++;
  733. X        else
  734. X            continue;
  735. X        AddResidentPrg( res->rl_SegList, buf);
  736. X        for(rpn=ArpBase->ResidentPrgList; rpn; rpn=rpn->rpn_Next)
  737. X            if( rpn->rpn_Segment==res->rl_SegList )
  738. X                rpn->rpn_Usage++;
  739. X    }
  740. X    Permit();
  741. X}
  742. X
  743. X#ifndef AZTEC_C
  744. X
  745. Xchar *
  746. Xrindex(char *s, int c)
  747. X{
  748. X    char *r;
  749. X
  750. X    for( r=NULL; *s; s++ )
  751. X        if( *s==c )
  752. X            r=s;
  753. X    return r;
  754. X}
  755. X
  756. Xint
  757. Xsetenv( char *var, char *val )
  758. X{
  759. X    char buf[300];
  760. X    sprintf(buf, "%s=%s", var, val );
  761. X    return putenv( buf );
  762. X}
  763. X
  764. Xint
  765. Xchkabort(void)
  766. X{
  767. X    return 0;
  768. X}
  769. X
  770. X#endif
  771. END_OF_FILE
  772. if test 8629 -ne `wc -c <'main.c'`; then
  773.     echo shar: \"'main.c'\" unpacked with wrong size!
  774. fi
  775. # end of 'main.c'
  776. fi
  777. if test -f 'makefile' -a "${1}" != "-c" ; then 
  778.   echo shar: Will not clobber existing file \"'makefile'\"
  779. else
  780. echo shar: Extracting \"'makefile'\" \(610 characters\)
  781. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  782. X######################################################################
  783. X# Makefile to build Shell 5.10  under Aztec C 5.0d
  784. X# make sure you use 5.0d or above, as setenv() has changed
  785. X# NOTE: Our chars are UNSIGNED by default, and the executable's called zsh
  786. X
  787. XOBJ=run.o main.o comm1.o comm2.o comm3.o execom.o set.o sub.o globals.o rawcon.o
  788. XINC=shell.syms
  789. X
  790. XFLAGS    = -pp -wurp -ssr
  791. XDEBUG    = -bs
  792. XPRECOM    = -hiShell.syms
  793. X
  794. Xzsh:  makefile shell.syms $(OBJ)
  795. X    ln -t +q -m -g -o zsh $(OBJ) -larpl -lc
  796. X
  797. Xshell.syms : shell.h proto.h
  798. X    cc -pp -hoShell.syms shell.h -DAZTEC_C
  799. X
  800. X$(OBJ): $(INC)
  801. X    cc $(DEBUG) $(FLAGS) $(PRECOM) $*.c
  802. END_OF_FILE
  803. if test 610 -ne `wc -c <'makefile'`; then
  804.     echo shar: \"'makefile'\" unpacked with wrong size!
  805. fi
  806. # end of 'makefile'
  807. fi
  808. if test -f 'menu.sh' -a "${1}" != "-c" ; then 
  809.   echo shar: Will not clobber existing file \"'menu.sh'\"
  810. else
  811. echo shar: Extracting \"'menu.sh'\" \(980 characters\)
  812. sed "s/^X//" >'menu.sh' <<'END_OF_FILE'
  813. X# This installs an intuition menu with all editing keys
  814. X
  815. Xmenu -n Move \
  816. X "Left         CursL",\
  817. X "Right        CursR",\
  818. X "WordLeft   S-CursL",\
  819. X "WordRight  S-CursR",\
  820. X "BegOfLine       ^A",^a\
  821. X "EndOfLine       ^E",^e
  822. X
  823. Xmenu  Delete \
  824. X "Left         BkSpc",^h\
  825. X "Right          Del",\177\
  826. X "WordLeft        ^W",^[^h\
  827. X "WordRight  ESC-Del",^[\177\
  828. X "To BOL          ^B",^[x^h\
  829. X "To EOL          ^K",^[x\177\
  830. X "Line            ^X",^[d
  831. X
  832. Xmenu History \
  833. X "Back         CursU",\
  834. X "Forward      CursD",\
  835. X "Start      S-CursU",\
  836. X "End        S-CursD",\
  837. X "Complete     ESC-!",^[!\
  838. X "Get tail        ^T",^T
  839. X
  840. Xmenu Complete \
  841. X "One            TAB",^I\
  842. X "Partial      S-TAB",\
  843. X "All        ESC-TAB",^[^I\
  844. X "QuickCD      ESC-c",^[c\
  845. X "LastCD       ESC-~",^[~
  846. X
  847. Xmenu Execute \
  848. X "Now         RETURN",^M\
  849. X "+Hist   ESC-RETURN",^[^M\
  850. X "Not             ^N",^N\
  851. X "Exit            ^\",
  852. X
  853. Xmenu Misc \
  854. X "Undo            ^U",^U\
  855. X "Repeat          ^R",\
  856. X "Retype          ^L",^L\
  857. X "Ins/Ovr      ESC-i",^[i
  858. X
  859. END_OF_FILE
  860. if test 980 -ne `wc -c <'menu.sh'`; then
  861.     echo shar: \"'menu.sh'\" unpacked with wrong size!
  862. fi
  863. # end of 'menu.sh'
  864. fi
  865. if test -f 'proto.h' -a "${1}" != "-c" ; then 
  866.   echo shar: Will not clobber existing file \"'proto.h'\"
  867. else
  868. echo shar: Extracting \"'proto.h'\" \(5741 characters\)
  869. sed "s/^X//" >'proto.h' <<'END_OF_FILE'
  870. X/* main.c */
  871. Xint main(int argc, char **argv);
  872. Xvoid main_exit(int n);
  873. Xint breakcheck(void);
  874. Xint dobreak(void);
  875. Xlong Chk_Abort(void);
  876. Xvoid _wb_parse(void);
  877. Xint do_howmany(void);
  878. Xvoid breakreset(void);
  879. X
  880. X/* comm1.c */
  881. Xint do_sleep(void);
  882. Xint do_protect(void);
  883. Xint do_filenote(void);
  884. Xint do_cat(void);
  885. Xvoid get_drives(char *buf);
  886. Xchar *drive_name(char *name);
  887. Xchar *oneinfo( char *name, int function );
  888. Xint do_info(void);
  889. Xint do_dir(void);
  890. Xint do_quit(void);
  891. Xint do_echo(void);
  892. Xint do_source(char *str );
  893. Xint do_pwd(char *str );
  894. Xint do_cd(char *str );
  895. Xchar *quick_cd( char *buf, char *name, int repeat );
  896. Xint do_mkdir(void);
  897. Xint do_mv(void);
  898. Xint all_args(int (*action)(char *str), int dirsflag);
  899. Xint do_search(void);
  900. Xint do_rm(void);
  901. Xint do_history(void);
  902. Xint do_mem(void);
  903. Xint do_forline(void);
  904. Xint do_fornum(void);
  905. Xint do_foreach(void);
  906. Xint do_forever(char *str);
  907. Xint do_window(void);
  908. Xchar *dates(struct DateStamp *dss, int flags);
  909. Xint do_date(void);
  910. X
  911. X/* comm2.c */
  912. Xint do_abortline(void);
  913. Xint do_return(void);
  914. Xint do_strhead(void);
  915. Xint do_strtail(void);
  916. Xint do_if(char *garbage, int com);
  917. Xint do_label(void);
  918. Xint do_goto(void);
  919. Xint do_inc(char *garbage, int com);
  920. Xint do_input(void);
  921. Xint do_ver(void);
  922. Xint do_ps(void);
  923. Xint do_copy(void);
  924. Xint do_touch(void);
  925. Xint do_addbuffers(void);
  926. Xint do_relabel(void);
  927. Xint do_diskchange(void);
  928. Xint dofunc(int id, char **av, int ac);
  929. Xint do_error( void );
  930. X
  931. X/* comm3.c */
  932. Xint do_tee(void);
  933. Xint do_head(char *garbage, int com);
  934. Xvoid man(struct __stdio *f, char *s);
  935. Xint do_man(void);
  936. Xint do_assign(void);
  937. Xchar **expand_devs(void);
  938. Xint do_join(void);
  939. Xint do_strings(void);
  940. Xint do_open(void);
  941. Xint do_close(void);
  942. Xvoid myclose(int n);
  943. Xint do_fileslist(void);
  944. Xlong extOpen(char *name, long mode);
  945. Xvoid extClose(long fh);
  946. Xint do_basename(void);
  947. Xint do_tackon(void);
  948. Xint do_resident(void);
  949. Xint loadres(char *s);
  950. Xint do_truerun(char *avline, int backflag);
  951. Xint exists(char *name);
  952. Xint do_aset(void);
  953. Xint do_htype(void);
  954. Xint do_stack(void);
  955. Xint do_fault(void);
  956. Xint eval_rpn(char **av, int ac, int flag);
  957. Xint do_rpn(char *garbage, int ifflag);
  958. Xint do_path(void);
  959. Xint do_pri(void);
  960. Xint do_strleft(void);
  961. Xint do_strright(void);
  962. Xint do_strmid(void);
  963. Xint do_strlen(void);
  964. Xint myatoi(char *s, int mmin, int mmax);
  965. Xint unlatoi(char *s);
  966. Xint posatoi(char *s);
  967. Xint do_fltlower(void);
  968. Xint do_fltupper(void);
  969. Xint do_linecnt(void);
  970. Xint do_uniq(void);
  971. Xint do_rxsend(char *avline);
  972. Xint do_rxrec(void);
  973. Xint do_rxreturn(void);
  974. Xint do_waitport(void);
  975. Xint do_ascii(void);
  976. Xvoid appendslash(char *path);
  977. Xint do_whereis(void);
  978. Xint do_usage(void);
  979. Xint do_menu(void);
  980. Xvoid remove_menu(void);
  981. Xvoid set_menu(void);
  982. Xint do_getenv(void);
  983. Xint do_setenv(void);
  984. Xchar **read_file(struct __stdio *file, int *ac);
  985. Xvoid free_file(char **ptr);
  986. Xint do_qsort(void);
  987. Xint do_truncate(void);
  988. Xint do_split(void);
  989. Xint do_action( char *argline );
  990. Xint do_class( char *avline );
  991. Xint do_readfile( void );
  992. X
  993. X/* execom.c */
  994. Xvoid *mymalloc(int len);
  995. Xint exec_command(char *base);
  996. X#ifndef isalphanum
  997. Xint isalphanum(char c);
  998. X#endif
  999. Xchar *exec_function(char *str, char **fav, int fac);
  1000. Xint do_help(void);
  1001. Xvoid exec_every(void);
  1002. Xvoid show_usage(char *str);
  1003. Xint do_exec(char *str);
  1004. Xint interactive(void);
  1005. Xchar *a0tospace(char *str);
  1006. Xint execute( char *str );
  1007. Xchar *find_internal(char *str);
  1008. X
  1009. X/* sub.c */
  1010. Xchar *getclass(char *file);
  1011. Xvoid seterr(int err);
  1012. Xchar *next_word(char *str);
  1013. Xchar *compile_av(char **av, int start, int end, char delim, int quote);
  1014. Xvoid Free(void *ptr);
  1015. Xvoid add_history(char *str);
  1016. Xchar *get_history(char *ptr, int echo);
  1017. Xvoid replace_head(char *str);
  1018. Xvoid pError(char *str);
  1019. Xint ierror(char *str, int err);
  1020. Xchar *ioerror(int num);
  1021. Xstruct DPTR *dopen(char *name, int *stat);
  1022. Xint dclose(struct DPTR *dp);
  1023. Xint isdir(char *file);
  1024. Xvoid free_expand(char **av);
  1025. Xchar **expand(char *base, int *pac);
  1026. Xchar *strupr(char *s);
  1027. Xchar *strlwr(char *s);
  1028. Xint compare_ok(char *wild, char *name, int casedep);
  1029. Xvoid expand_all(char *name, struct __stdio *file);
  1030. Xint cmp(struct file_info *s1, struct file_info *s2);
  1031. Xint sizecmp(struct file_info *s1, struct file_info *s2);
  1032. Xint datecmp(struct file_info *s1, struct file_info *s2);
  1033. Xint classcmp(struct file_info *s1, struct file_info *s2);
  1034. Xint numcmp( struct file_info *s1, struct file_info *s2 );
  1035. Xvoid QuickSort(char **av, int n);
  1036. Xvoid DirQuickSort(char **av,int n,int (*func)(struct file_info *,struct file_info *), int rev, int fac);
  1037. Xint filesize(char *name);
  1038. Xchar **and(char **av1, int ac1, char **av2, int ac2, int *ac, int base);
  1039. Xchar **without(char **av1, int ac1, char **av2, int ac2, int *ac, int base);
  1040. Xchar **or(char **av1, int ac1, char **av2, int ac2, int *ac, int base);
  1041. Xvoid clear_archive_bit(char *name);
  1042. Xchar *itoa( int i );
  1043. Xchar *itok( int i );
  1044. Xchar *getaction( char *class, char *action );
  1045. Xint doaction( char *file, char *action, char *args );
  1046. Xvoid *salloc( int len );
  1047. Xvoid *SAllocMem( long size, long req );
  1048. Xvoid setioerror( int err );
  1049. X
  1050. X/* set.c */
  1051. Xvoid init_mbase(void);
  1052. Xvoid set_var(int level, char *name, char *str);
  1053. Xvoid update_sys_var( char *name );
  1054. Xvoid set_var_n(int level, char *name, char *str, int n);
  1055. Xchar *get_var(int level, char *name);
  1056. Xvoid unset_level(int level);
  1057. Xvoid unset_var(int level, char *name);
  1058. Xint do_unset_var(char *str, int level);
  1059. Xint do_set_var(char *command, int level);
  1060. Xvoid push_locals( struct VRoot *newroot );
  1061. Xvoid pop_locals( void );
  1062. Xint do_local(void);
  1063. X
  1064. X/* rawconsole.c */
  1065. Xint newwidth(void);
  1066. Xvoid initmap(void);
  1067. Xchar *rawgets(char line[], char prompt[]);
  1068. Xvoid prepscroll(int fromtee);
  1069. Xvoid quickscroll(void);
  1070. Xvoid setrawcon( long flag, int ievent );
  1071. Xint do_keymap( void );
  1072. X
  1073. X/* run.c */
  1074. Xint do_run(char *str);
  1075. Xchar *dofind(char *cmd, char *ext, char *buf, char *path);
  1076. X
  1077. Xchar *index(char *_s, int _c);
  1078. Xchar *rindex(char *_s, int _c);
  1079. Xint setenv(char *var, char *val);
  1080. END_OF_FILE
  1081. if test 5741 -ne `wc -c <'proto.h'`; then
  1082.     echo shar: \"'proto.h'\" unpacked with wrong size!
  1083. fi
  1084. # end of 'proto.h'
  1085. fi
  1086. if test -f 'run.c' -a "${1}" != "-c" ; then 
  1087.   echo shar: Will not clobber existing file \"'run.c'\"
  1088. else
  1089. echo shar: Extracting \"'run.c'\" \(4740 characters\)
  1090. sed "s/^X//" >'run.c' <<'END_OF_FILE'
  1091. X
  1092. X/*
  1093. X * RUN.C
  1094. X *
  1095. X * (c)1986 Matthew Dillon     9 October 1986
  1096. X *
  1097. X *    RUN   handles running of external commands.
  1098. X *
  1099. X * Version 2.07M by Steve Drew 10-Sep-87
  1100. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1101. X * Version 5.00L by Urban Mueller 17-Feb-91
  1102. X *
  1103. X */
  1104. X
  1105. X#include "shell.h"
  1106. X
  1107. Xint MySyncRun( char *com, char *args, BPTR in, BPTR out );
  1108. Xint echofunc(void);
  1109. X
  1110. Xint
  1111. Xdo_run( char *str )
  1112. X{
  1113. X    int retcode;
  1114. X    char buf[200]; /* enough space for 100 char cmd name + path stuff */
  1115. X    char *path, *argline, *copy, *ext, *end;
  1116. X
  1117. X    if( !*av[0] )
  1118. X        return 0;
  1119. X
  1120. X    if( (retcode=echofunc())>=0 )
  1121. X        return retcode;
  1122. X
  1123. X    a0tospace( av[0] );                                 /* allow "com mand" */
  1124. X
  1125. X    argline=compile_av(av, 1, ac, ' ', 1);
  1126. X    strcat(argline,"\n");
  1127. X
  1128. X    if (strlen(av[0]) > 100) { ierror(NULL,509); return -1; }
  1129. X
  1130. X    if( !strcmp(av[0],".bra") || !strcmp(av[0],".ket") ) return 0;
  1131. X
  1132. X    if( ac==1 && isdir(av[0])) {
  1133. X        sprintf(buf,"cd %s",av[0]);
  1134. X        return execute( buf );
  1135. X    }
  1136. X
  1137. X    sprintf(buf,"res_%s",BaseName(av[0]));              /* delayed residents */
  1138. X    if (o_resident && Getenv(buf, buf+100, 90L) && loadres(av[0]))
  1139. X        Setenv(buf,NULL);
  1140. X
  1141. X    if( (retcode=MySyncRun(av[0],argline,0L,0L))>=0 )   /* AmigaDOS path */
  1142. X        goto done2;
  1143. X
  1144. X    IoError=IoErr();
  1145. X    if( (IoError==218 || IoError==225 || IoError==226) && index(av[0],':')) {
  1146. X        ierror( av[0], IoError );
  1147. X        return 20;
  1148. X    }
  1149. X
  1150. X    strcpy(buf,"Execute ");
  1151. X    if (path = dofind(av[0],"",buf+8,v_path)) {             /* shell path    */
  1152. X        if((retcode = MySyncRun(path,argline,0L,0L))>=0)
  1153. X            goto done2;
  1154. X        else {
  1155. X            struct DPTR *dp;
  1156. X            int stat;
  1157. X            if(dp=dopen(path,&stat)) {
  1158. X                stat= !stat && dp->fib->fib_Protection & FIBF_SCRIPT;
  1159. X                dclose(dp);
  1160. X                if( stat ) {
  1161. X                    execute(buf);
  1162. X                    return 0;
  1163. X                }
  1164. X            }
  1165. X        }
  1166. X    }
  1167. X
  1168. X    if(!(end=rindex(av[0],'.'))) end="";               /* automatic sourcing */
  1169. X    ext=strcmp(end,".sh") ? ".sh" : "";
  1170. X    if (path = dofind(av[0],ext,buf,v_path)) {
  1171. X        av[1] = buf;
  1172. X        copy = salloc(strlen(str)+3);
  1173. X        sprintf(copy,"x %s",str);
  1174. X        retcode = do_source(copy);
  1175. X        goto done;
  1176. X    }
  1177. X
  1178. X    copy=salloc(strlen(av[0])+strlen(argline)+5);
  1179. X    sprintf(copy,"%s %s",av[0],argline);
  1180. X
  1181. X    ext=strcmp(end,".rexx") ? ".rexx" : "";           /* automatic rx-ing   */
  1182. X    if( path = dofind(av[0], ext, buf, v_rxpath )) {
  1183. X        if( (retcode=MySyncRun("rx",copy,0L,0L)) >=0 ) goto done;
  1184. X        if (path = dofind("rx","",buf,v_path)) {
  1185. X            retcode = MySyncRun(path,copy,0L,0L);
  1186. X            goto done;
  1187. X        }
  1188. X    }
  1189. X
  1190. X    if( !doaction(av[0],"exec",argline)) {
  1191. X        retcode=0;
  1192. X        goto done;
  1193. X    }
  1194. X
  1195. X    retcode=-1;
  1196. X    fprintf(stderr,"Command not found %s\n",av[0]);
  1197. X
  1198. Xdone:
  1199. X    free( copy );
  1200. Xdone2:
  1201. X    setioerror( IoErr() );
  1202. X    free( argline );
  1203. X    return retcode;
  1204. X}
  1205. X
  1206. Xstruct Segment {
  1207. X    BPTR NextEntry;
  1208. X    LONG UseCount;
  1209. X    BPTR SegPtr;
  1210. X    BSTR SegName;
  1211. X};
  1212. X
  1213. Xint
  1214. XMySyncRun( char *com, char *args, BPTR in, BPTR out )
  1215. X{
  1216. X    struct Segment *seg;
  1217. X    int ret;
  1218. X    char buf2[200], *buf=buf2;
  1219. X    long oldname;
  1220. X
  1221. X#ifdef KICK20
  1222. X    if( o_kick20 ) {
  1223. X        oldname = (long)Mycli->cli_CommandName;
  1224. X
  1225. X        while( (long)buf & 3 ) buf++;
  1226. X        buf[0] = strlen( com );
  1227. X        strncpy(buf+1,com,80);
  1228. X
  1229. X        Forbid();
  1230. X        seg=FindSegment( (UBYTE *)com, NULL, 0 );
  1231. X        Permit();
  1232. X        if( seg ) {
  1233. X            Mycli->cli_CommandName = (long)buf/4;
  1234. X            seg->UseCount++;
  1235. X
  1236. X            ret=RunCommand(seg->SegPtr, Mycli->cli_DefaultStack,
  1237. X                                       (UBYTE *)args, strlen(args));
  1238. X            seg->UseCount--;
  1239. X            Mycli->cli_CommandName = (long)oldname;
  1240. X            return ret;
  1241. X        }
  1242. X
  1243. X        if( o_internal ) {
  1244. X            Forbid();
  1245. X            seg=FindSegment( (UBYTE *)com, NULL, 1 );
  1246. X            Permit();
  1247. X            if( seg ) {
  1248. X                Mycli->cli_CommandName = (long)buf/4;
  1249. X
  1250. X                ret=RunCommand(seg->SegPtr, Mycli->cli_DefaultStack,
  1251. X                                           (UBYTE *)args, strlen(args));
  1252. X                Mycli->cli_CommandName = (long)oldname;
  1253. X                return ret;
  1254. X            }
  1255. X        }
  1256. X
  1257. X    }
  1258. X#endif
  1259. X
  1260. X    if( !Strcmp(BaseName(com), "Execute")) {
  1261. X        sprintf(buf2,"%s %s",com,args);
  1262. X        Execute(buf2,0,0);
  1263. X        return 0;
  1264. X    }
  1265. X
  1266. X    if( (ret= SyncRun( com, args, in, out ))>=0 )
  1267. X        return ret;
  1268. X
  1269. X    return ret;
  1270. X}
  1271. X
  1272. X#if 0
  1273. Xint
  1274. Xdo_which( char *str )
  1275. X{
  1276. X    char *got, *com=av[1];
  1277. X
  1278. X    if( get_var(LEVEL_ALIAS,com) ) {
  1279. X        printf("Shell Alias '%s'\n",com);
  1280. X        return 0;
  1281. X    }
  1282. X
  1283. X    if( *(got=find_internal( com ))>1 ) {
  1284. X        printf("Shell Internal '%s'\n",got);
  1285. X        return 0;
  1286. X    }
  1287. X
  1288. X
  1289. X
  1290. X    printf( "Not found\n" );
  1291. X    return 20;
  1292. X}
  1293. X#endif
  1294. X
  1295. X
  1296. Xchar *
  1297. Xdofind( char *cmd, char *ext, char *buf, char *path)
  1298. X{
  1299. X    char *ptr, *s=path, *ret=NULL;
  1300. X
  1301. X    Myprocess->pr_WindowPtr = (APTR)(-1);
  1302. X    sprintf(buf,"%s%s",cmd,ext);
  1303. X    if (exists(buf)) {
  1304. X        ret=buf;
  1305. X        goto exit;
  1306. X    }
  1307. X    if (BaseName(buf)==buf) {
  1308. X        if( *path=='_' )
  1309. X            s = get_var(LEVEL_SET, path);
  1310. X        while (*s) {
  1311. X            for (ptr=buf; *s && *s!=','; ) *ptr++ = *s++;
  1312. X            if( ptr[-1]!=':' && ptr[-1]!='/')
  1313. X                *ptr++='/';
  1314. X            sprintf(ptr, "%s%s", cmd, ext);
  1315. X            if (exists(buf)) {
  1316. X                ret=buf;
  1317. X                goto exit;
  1318. X            }
  1319. X            if (*s) s++;
  1320. X        }
  1321. X    }
  1322. Xexit:
  1323. X    Myprocess->pr_WindowPtr = (APTR)o_noreq;
  1324. X    return ret;
  1325. X}
  1326. END_OF_FILE
  1327. if test 4740 -ne `wc -c <'run.c'`; then
  1328.     echo shar: \"'run.c'\" unpacked with wrong size!
  1329. fi
  1330. # end of 'run.c'
  1331. fi
  1332. if test -f 'sample.sh' -a "${1}" != "-c" ; then 
  1333.   echo shar: Will not clobber existing file \"'sample.sh'\"
  1334. else
  1335. echo shar: Extracting \"'sample.sh'\" \(1100 characters\)
  1336. sed "s/^X//" >'sample.sh' <<'END_OF_FILE'
  1337. X# first a few useful aliases
  1338. Xal d   "dir -hq"  # hides .info and block lengths
  1339. Xal lst "ls -t"    # sorts by access time
  1340. Xal lsl "ls -l"    # sorts by length
  1341. X
  1342. X# sc searches *.c, even 'sc -c main()' works
  1343. Xal sc "%a search @pickopts( $a ) *.c @pickargs( $a )
  1344. X
  1345. X# edf edits a function in CygnusEd if the name starts in the first column:
  1346. Xal edf "%func set b \"\";search -afl *.c $func | inp b;\
  1347. X if $b;split b file line;ed $file;waitforport rexx_ced;\
  1348. X  inc line 1;rxs rexx_ced \"jump to file \"$file \"jumpto \"$line\" 0\";\
  1349. X else;\
  1350. X  echo Not found;\
  1351. X endif
  1352. X
  1353. X# this aliases suppress wild card expansion for certain commands
  1354. Xal zoo     "*a Zoo $a
  1355. Xal lharc   "*a Lharc $a
  1356. Xal lz      "*a Lz $a
  1357. Xal newlist "*a Newlist $a
  1358. X
  1359. X# pushd pushes the current directory on a stack
  1360. X# popd  retrieves it from there
  1361. Xset stk ""
  1362. Xal pushd   "set stk $_cwd @subwords( $stk 1 10 )
  1363. Xal popd    "\\cd @first( $stk );set stk @subwords( $stk 2 10 )
  1364. X
  1365. X# this one will show all pictures, the newest first
  1366. Xal newpix  "ls -nt | forline i STDIN \"ShowIFF $i
  1367. X
  1368. X# shift-arrow-up will retrieve an abbreviated line from history
  1369. Xkeymap 0 768=24
  1370. END_OF_FILE
  1371. if test 1100 -ne `wc -c <'sample.sh'`; then
  1372.     echo shar: \"'sample.sh'\" unpacked with wrong size!
  1373. fi
  1374. # end of 'sample.sh'
  1375. fi
  1376. if test -f 'set.c' -a "${1}" != "-c" ; then 
  1377.   echo shar: Will not clobber existing file \"'set.c'\"
  1378. else
  1379. echo shar: Extracting \"'set.c'\" \(7922 characters\)
  1380. sed "s/^X//" >'set.c' <<'END_OF_FILE'
  1381. X
  1382. X/*
  1383. X * SET.C
  1384. X *
  1385. X * (c)1986 Matthew Dillon     9 October 1986
  1386. X *
  1387. X * Version 2.07M by Steve Drew 10-Sep-87
  1388. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1389. X * Version 5.00L by Urban Mueller 17-Feb-91
  1390. X *
  1391. X */
  1392. X
  1393. X#include "shell.h"
  1394. X
  1395. Xstatic char *sys_expand( char *str, char *t );
  1396. Xstatic void set_sys_var( char *name );
  1397. X
  1398. X#define MAXLEVELS (4+MAXSRC)
  1399. X
  1400. XROOT _Mbase[MAXLEVELS], *Mbase[ MAXLEVELS ];
  1401. X
  1402. Xvoid
  1403. Xinit_mbase(void)
  1404. X{
  1405. X    int i;
  1406. X    for( i=0; i<MAXLEVELS; i++ )
  1407. X        Mbase[i]=&_Mbase[i];
  1408. X}
  1409. X
  1410. Xvoid
  1411. Xset_var( int level, char *name, char *str )
  1412. X{
  1413. X    NODE **first, *node;
  1414. X    char *t, c;
  1415. X    int  truelevel=level;
  1416. X
  1417. X    if( !str ) str="";
  1418. X
  1419. X    for( t=name; isalphanum(*t); t++ ) ;
  1420. X    c=*t; *t=0;
  1421. X
  1422. X    if( level==LEVEL_SET ) level=LEVEL_LOCAL;
  1423. X
  1424. X    for( ;; ) {
  1425. X        first=&Mbase[level]->first[*name & MAXHASH-1];
  1426. X        for( node=*first; node; node=node->next )
  1427. X            if( !strcmp( node->name, name) ) {
  1428. X                free( node->text );
  1429. X                goto copy;
  1430. X            }
  1431. X        if( truelevel!=LEVEL_SET )
  1432. X            break;
  1433. X        level=LEVEL_SET, truelevel=-1;
  1434. X    }
  1435. X
  1436. X    if(!(node=malloc(sizeof(NODE) + strlen(name)))) {
  1437. X        ierror(NULL,512);
  1438. X        return;
  1439. X    }
  1440. X    node->next=*first;
  1441. X    *first=node;
  1442. X    strcpy( node->name, name );
  1443. X
  1444. Xcopy:
  1445. X    if(!(node->text=malloc(strlen(str)+1))) {
  1446. X        ierror(NULL,512);
  1447. X        return;
  1448. X    }
  1449. X    strcpy( node->text, str );
  1450. X    *t=c;
  1451. X    if( *name=='_' )
  1452. X        set_sys_var( name );
  1453. X}
  1454. X
  1455. X
  1456. Xchar *
  1457. Xget_var( int level, char *name )
  1458. X{
  1459. X    NODE *node;
  1460. X    char *t, c;
  1461. X    int  truelevel=level;
  1462. X
  1463. X    if( level==LEVEL_SET ) level=LEVEL_LOCAL;
  1464. X
  1465. X    for ( t= name; (signed char)*t>0; t++ ) ;
  1466. X    c=*t; *t=0;
  1467. X
  1468. X    for( ;; ) {
  1469. X        node=Mbase[level]->first[*name & MAXHASH-1];
  1470. X
  1471. X        for( ; node; node=node->next )
  1472. X            if( !strcmp(node->name,name) )
  1473. X                { *t=c; return node->text; }
  1474. X        if( truelevel!=LEVEL_SET )
  1475. X            break;
  1476. X        level=LEVEL_SET, truelevel=-1;
  1477. X    }
  1478. X
  1479. X    *t=c;
  1480. X
  1481. X    return NULL;
  1482. X}
  1483. X
  1484. Xvoid
  1485. Xunset_level( int level )
  1486. X{
  1487. X    NODE *node;
  1488. X    int i;
  1489. X
  1490. X    for( i=0; i<MAXHASH; i++ ) {
  1491. X        for( node=Mbase[level]->first[i]; node; node=node->next ) {
  1492. X            Free ( node->text );
  1493. X            Free ( node );
  1494. X        }
  1495. X        Mbase[level]->first[i] = NULL;
  1496. X    }
  1497. X}
  1498. X
  1499. Xvoid
  1500. Xunset_var( int level, char *name )
  1501. X{
  1502. X    NODE **first=&Mbase[level]->first[*name & MAXHASH-1], *node, *prev;
  1503. X    char *t, c;
  1504. X
  1505. X    for( t=name; isalphanum(*t); t++ ) ;
  1506. X    c=*t; *t=0;
  1507. X
  1508. X    for( node=*first, prev=NULL; node; prev=node, node=node->next )
  1509. X        if( !strcmp( node->name, name) ) {
  1510. X            if( prev ) prev->next=node->next; else *first=node->next;
  1511. X            Free( node->text );
  1512. X            Free( node );
  1513. X            if( *name=='_' )
  1514. X                set_sys_var( name );
  1515. X            break;
  1516. X        }
  1517. X    *t=c;
  1518. X}
  1519. X
  1520. X
  1521. Xvoid
  1522. Xset_var_n( int level, char *name, char *str, int n )
  1523. X{
  1524. X    char c, len=strlen(str);
  1525. X
  1526. X    if( n>len )
  1527. X        n=len;
  1528. X
  1529. X    if( n>=0 ) {
  1530. X        c=str[n]; str[n]=0;
  1531. X        set_var( level, name, str );
  1532. X        str[n]=c;
  1533. X    } else 
  1534. X        set_var( level, name, "" );
  1535. X}
  1536. X
  1537. Xint
  1538. Xdo_unset_var( char *str, int level )
  1539. X{
  1540. X    int i;
  1541. X
  1542. X    for (i = 1; i < ac; ++i)
  1543. X        unset_var (level, av[i]);
  1544. X    return 0;
  1545. X}
  1546. X
  1547. Xint
  1548. Xdo_set_var( char *command, int level )
  1549. X{
  1550. X    ROOT *root = Mbase[level];
  1551. X    NODE *node;
  1552. X    int i;
  1553. X    char *str;
  1554. X
  1555. X    switch (ac) {
  1556. X    case 1:
  1557. X        for( i=0; i<MAXHASH && !breakcheck(); i++ )
  1558. X            for( node=root->first[i]; node && !dobreak(); node=node->next )
  1559. X                printf ("%s%-10s %s\n", o_lolite, node->name, node->text);
  1560. X        break;
  1561. X    case 2:
  1562. X        if (str=get_var(level,av[1])) printf ("%-10s %s\n", av[1], str);
  1563. X        break;
  1564. X    default:
  1565. X        set_var (level, av[1], next_word (next_word (command)));
  1566. X        break;
  1567. X    }
  1568. X    return 0;
  1569. X}
  1570. X
  1571. X
  1572. Xextern char shellvers[];
  1573. X
  1574. Xstatic char *
  1575. Xsys_expand( char *str, char *t )
  1576. X{
  1577. X    struct DateStamp dss;
  1578. X    char *u;
  1579. X    DateStamp(&dss);
  1580. X
  1581. X    if( !str ) {
  1582. X        *t=0;
  1583. X        return t;
  1584. X    }
  1585. X
  1586. X    while (*str)
  1587. X        if (*str=='%') {
  1588. X            str+=2;
  1589. X            switch( str[-1] ) {
  1590. X            case 'p': t+=sprintf(t,"%s", get_var(LEVEL_SET, "_cwd"));  break;
  1591. X            case 'm': t+=sprintf(t,"%d", AvailMem( 0 )/1024);          break;
  1592. X            case 't': t+=sprintf(t,"%s", next_word(dates(&dss,0)));    break;
  1593. X            case 'c': t+=sprintf(t,"%s", o_hilite);                    break;
  1594. X            case 'v': t+=sprintf(t,"%s", shellvers );                  break;
  1595. X            case 'n': t+=sprintf(t,"%s", get_var(LEVEL_SET,"_clinumber"));break;
  1596. X            case 'h': t+=sprintf(t,"%s", get_var(LEVEL_SET, v_histnum));  break;
  1597. X            case 'd':    sprintf(t,"%s", dates(&dss,0));if(u=index(t,' '))t=u;break;
  1598. X            case 'f': t+=sprintf(t,"%s", oneinfo(get_var(LEVEL_SET,v_cwd),4));break;
  1599. X            case 'r': t+=sprintf(t,"%d", (SBYTE)Myprocess->pr_Task.tc_Node.ln_Pri);break;
  1600. X            default : *t++=str[-2]; *t++=str[-1]; break;
  1601. X            }
  1602. X        }
  1603. X        else *t++=*str++;
  1604. X    *t=0;
  1605. X    return t;
  1606. X}
  1607. X
  1608. Xvoid
  1609. Xpush_locals( ROOT *newroot )
  1610. X{
  1611. X    int i;
  1612. X    NODE **nodeptr;
  1613. X
  1614. X    newroot->prev=Mbase[ LEVEL_LOCAL ];
  1615. X    Mbase[ LEVEL_LOCAL ]=newroot;
  1616. X
  1617. X    nodeptr=newroot->first;
  1618. X    for( i=MAXHASH; i>0; --i )
  1619. X        *nodeptr++=NULL;
  1620. X
  1621. X}
  1622. X
  1623. Xvoid
  1624. Xpop_locals( void )
  1625. X{
  1626. X    ROOT *prev=Mbase[ LEVEL_LOCAL ]->prev;
  1627. X    unset_level( LEVEL_LOCAL );
  1628. X    Mbase[ LEVEL_LOCAL ]=prev;
  1629. X}
  1630. X
  1631. Xint
  1632. Xdo_local(void)
  1633. X{
  1634. X    int i;
  1635. X
  1636. X    if( ac==1 )
  1637. X        do_set_var( "", LEVEL_LOCAL);
  1638. X    else 
  1639. X        for( i=1; i<ac; i++ )
  1640. X            set_var(LEVEL_LOCAL,av[i],"");
  1641. X    return 0;
  1642. X}
  1643. X
  1644. X
  1645. Xchar truetitle[200];
  1646. X
  1647. Xchar o_hilite[24], o_lolite[8], *o_csh_qcd, o_kick20, o_nobreak;
  1648. Xchar o_minrows, o_scroll, o_nowindow, o_noraw, o_vt100, o_nofastscr;
  1649. Xchar o_bground, o_resident, o_internal, o_pipe[16]="T:", o_datefmt;
  1650. Xchar o_abbrev=1;
  1651. Xlong o_noreq;
  1652. X
  1653. Xextern char trueprompt[100];
  1654. X
  1655. Xstatic void
  1656. Xset_sys_var( char *name )
  1657. X{
  1658. X    char *get, *str, c=name[1], col;
  1659. X
  1660. X    if( c==v_debug  [1] ) debug  =  get_var(LEVEL_SET,v_debug  )!=NULL;
  1661. X    if( c==v_nobreak[1] ) o_nobreak=get_var(LEVEL_SET,v_nobreak)!=NULL;
  1662. X    if( c==v_abbrev [1] && (str=get_var(LEVEL_SET,v_abbrev)))o_abbrev=*str!='n';
  1663. X
  1664. X    if( c==v_verbose[1] ) {
  1665. X        Verbose=0;
  1666. X        if( str=get_var(LEVEL_SET,v_verbose)) {
  1667. X            if( index(str,'s' )) Verbose|= VERBOSE_SOURCE;
  1668. X            if( index(str,'a' )) Verbose|= VERBOSE_ALIAS;
  1669. X            if( index(str,'h' )) Verbose|= VERBOSE_HILITE;
  1670. X        }
  1671. X    }
  1672. X    if( c==v_pipe   [1] ) {
  1673. X        strcpy(o_pipe,"t:");
  1674. X        if( str=get_var(LEVEL_SET,v_pipe) )
  1675. X            strcpy(o_pipe,str);
  1676. X        appendslash(o_pipe);
  1677. X    }
  1678. X    if( c==v_hilite [1] && !strcmp( name, v_hilite)) {
  1679. X        o_hilite[0]=o_lolite[0]=0;
  1680. X        get= get_var(LEVEL_SET,v_hilite);
  1681. X        str= o_hilite;
  1682. X        while( get && *get ) {
  1683. X            switch( *get++ ) {
  1684. X            case 'b': str+=sprintf( str, "\033[1m" ); break;
  1685. X            case 'i': str+=sprintf( str, "\033[3m" ); break;
  1686. X            case 'u': str+=sprintf( str, "\033[4m" ); break;
  1687. X            case 'r': str+=sprintf( str, "\033[7m" ); break;
  1688. X            case 'c': str+=strlen(str);
  1689. X                      if( *get>='0' && *get<='9' ) {
  1690. X                         col=*get++;
  1691. X                         if( *get==',' && get[1]>='0' && get[1]<='9' ) {
  1692. X                             str+=sprintf( str,"\033[3%cm\033[4%cm",col,get[1]);
  1693. X                             get+=2;
  1694. X                         } else 
  1695. X                             str+=sprintf( str,"\033[3%cm",col );
  1696. X                      }
  1697. X                      break;
  1698. X            }
  1699. X        }
  1700. X        *str=0;
  1701. X        if( *o_hilite )
  1702. X            strcpy(o_lolite,"\033[m");
  1703. X        strcpy(sys_expand(str,trueprompt),o_lolite);
  1704. X    }
  1705. X    if( c==v_scroll[1] ) {
  1706. X        o_scroll=0;
  1707. X        if( (str= get_var(LEVEL_SET,v_scroll))) {
  1708. X            o_scroll=atoi( str );
  1709. X            if( o_scroll<2 ) o_scroll=0;
  1710. X            if( o_scroll>8 ) o_scroll=8;
  1711. X        }
  1712. X    }
  1713. X    if( c==v_datefmt[1] ) {
  1714. X        o_datefmt=(str=get_var(LEVEL_SET,v_datefmt)) && !strcmp(str,"subst");
  1715. X    }
  1716. X    if( c==v_minrows[1] ) {
  1717. X        o_minrows=34;
  1718. X        if( (str= get_var(LEVEL_SET,v_minrows))) {
  1719. X            o_minrows=atoi( str );
  1720. X            if( o_minrows<8 )   o_minrows=8;
  1721. X            if( o_minrows>100 ) o_minrows=100, o_scroll=0;
  1722. X        }
  1723. X    }
  1724. X    if( c==v_qcd[1] ) {
  1725. X        o_csh_qcd="s:csh-qcd";
  1726. X        if( str=get_var(LEVEL_SET,v_qcd) )
  1727. X            o_csh_qcd=str;
  1728. X    }
  1729. X    if( c==v_noreq[1] ) {
  1730. X        o_noreq= get_var(LEVEL_SET,v_noreq ) ? -1 : 0;
  1731. X        Myprocess->pr_WindowPtr = (APTR)o_noreq;
  1732. X    }
  1733. X    if( c==v_hist[1] )
  1734. X        S_histlen=(str= get_var(LEVEL_SET, v_hist)) ? atoi(str) : 0;
  1735. X    if( c==v_titlebar[1] )
  1736. X        update_sys_var( v_titlebar );
  1737. X}
  1738. X
  1739. Xvoid
  1740. Xupdate_sys_var( char *name )
  1741. X{
  1742. X    char c=name[1], *str, buf[250];
  1743. X
  1744. X    if( c==v_prompt[1] ) {
  1745. X        if( (str=get_var(LEVEL_SET,v_prompt) ) ==NULL) str="$ ";
  1746. X        strcpy(sys_expand(str,trueprompt),o_lolite);
  1747. X    }
  1748. X    if( c==v_titlebar[1] && !o_nowindow && Win ) {
  1749. X        sys_expand( get_var(LEVEL_SET, v_titlebar), buf);
  1750. X        if (strcmp((char*)Win->Title, buf)) {
  1751. X            strcpy(truetitle,buf);
  1752. X            SetWindowTitles(Win, truetitle, (char *)-1);
  1753. X        }
  1754. X    }
  1755. X}
  1756. END_OF_FILE
  1757. if test 7922 -ne `wc -c <'set.c'`; then
  1758.     echo shar: \"'set.c'\" unpacked with wrong size!
  1759. fi
  1760. # end of 'set.c'
  1761. fi
  1762. if test -f 'shell.h' -a "${1}" != "-c" ; then 
  1763.   echo shar: Will not clobber existing file \"'shell.h'\"
  1764. else
  1765. echo shar: Extracting \"'shell.h'\" \(6349 characters\)
  1766. sed "s/^X//" >'shell.h' <<'END_OF_FILE'
  1767. X
  1768. X/*
  1769. X * SHELL.H
  1770. X *
  1771. X * (c)1986 Matthew Dillon     9 October 1986
  1772. X *
  1773. X *
  1774. X * SHELL include file.. contains shell parameters and extern's
  1775. X *
  1776. X * Version 2.07M by Steve Drew 10-Sep-87
  1777. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1778. X * Version 5.00L by Urban Mueller 16-Mar-91
  1779. X *
  1780. X */
  1781. X
  1782. X#define RAW_CONSOLE 1   /* Set to 0 to compile out Cmd Line Editing */
  1783. X#define KICK20
  1784. X
  1785. X#ifdef DICE
  1786. X
  1787. X#define    C_Args
  1788. X#define char unsigned char
  1789. X
  1790. X#endif
  1791. X
  1792. X#define strlen strlen
  1793. X
  1794. X#include <exec/types.h>
  1795. X#include <exec/exec.h>
  1796. X#include <libraries/arpbase.h>
  1797. X#include <intuition/intuitionbase.h>
  1798. X#include <libraries/dosextens.h>
  1799. X#include <time.h>
  1800. X#include <ctype.h>
  1801. X#include <fcntl.h>
  1802. X#include <stdio.h>
  1803. X#include <stdlib.h>
  1804. X#include <string.h>
  1805. X#include "proto.h"
  1806. X
  1807. XLONG AssignLock( UBYTE *name, BPTR lock );
  1808. XBOOL AssignLate( UBYTE *name, UBYTE *path );
  1809. XBOOL AssignPath( UBYTE *name, UBYTE *path );
  1810. XBOOL AssignAdd( UBYTE *name, BPTR lock );
  1811. X
  1812. Xtypedef struct FileInfoBlock FIB;
  1813. X
  1814. X#ifdef AZTEC_C
  1815. X
  1816. X#include <functions.h>
  1817. X#define DEVTAB(x) (BPTR)(_devtab[x->_unit].fd)
  1818. X#define CHARSWAIT(x) (x->_bp < x->_bend)
  1819. X#define COMPILER "Aztec C 5.0d"
  1820. X#pragma amicall(DOSBase, 0x264, AssignLock(d1,d2))
  1821. X#pragma amicall(DOSBase, 0x26a, AssignLate(d1,d2))
  1822. X#pragma amicall(DOSBase, 0x270, AssignPath(d1,d2))
  1823. X#pragma amicall(DOSBase, 0x276, AssignAdd(d1,d2))
  1824. X
  1825. X#else
  1826. X
  1827. X#include <proto/all.h>
  1828. X#include <ios1.h>
  1829. X#define DEVTAB(x) _ufbs[(x)->_file].ufbfh
  1830. X#define CHARSWAIT(x) (x->_rcnt != x->_wcnt)
  1831. X
  1832. X  extern struct UFB _ufbs[];
  1833. X#ifndef memmove
  1834. X#define memmove(t,f,l) movmem((f),(t),(l))
  1835. X#endif
  1836. X#define COMPILER "Lattice C 5.10"
  1837. X#define index strchr
  1838. X#define swapmem(x,y,z) swmem(x,y,z)
  1839. X#pragma libcall DOSBase AssignLock 264 2102
  1840. X#pragma libcall DOSBase AssignLate 26a 2102
  1841. X#pragma libcall DOSBase AssignPath 270 2102
  1842. X#pragma libcall DOSBase AssignAdd 276 2102
  1843. X
  1844. X#endif
  1845. X
  1846. X#ifndef MAX
  1847. X#define MAX(x,y) ((x)>(y) ? (x) : (y))
  1848. X#endif
  1849. X
  1850. X#define MAXSRC        5        /* Max. # of source file levels    */
  1851. X#define MAXIF        10        /* Max. # of if levels            */
  1852. X#define MAXALIAS    20        /* Max. # of alias levels        */
  1853. X#define MAXMYFILES    9        /* Max. # of internal files        */
  1854. X#define MAXHASH        32        /* Max. # of hash chains        */
  1855. X
  1856. X#define LEVEL_SET        0        /* which variable list to use   */
  1857. X#define LEVEL_ALIAS        1
  1858. X#define LEVEL_LABEL        2
  1859. X#define LEVEL_LOCAL        3
  1860. X#define LEVEL_SOURCE    3
  1861. X
  1862. X#define SBYTE signed char
  1863. X#define MAXITEMS 16
  1864. X#define MAXMENUS 6
  1865. X
  1866. X#define VERBOSE_SOURCE 1
  1867. X#define VERBOSE_ALIAS  2
  1868. X#define VERBOSE_HILITE 4
  1869. X
  1870. X#ifndef NULL
  1871. X#define NULL 0L
  1872. X#endif
  1873. X
  1874. X#define CHECKBREAK() dobreak()
  1875. X
  1876. X#ifndef AZTEC_C
  1877. Xstruct _dev {
  1878. X    long  fd;
  1879. X    short mode;
  1880. X    };
  1881. X#endif
  1882. X
  1883. Xstruct HIST {
  1884. X    struct HIST *next, *prev;    /* doubly linked list */
  1885. X    char *line;                    /* line in history    */
  1886. X};
  1887. X
  1888. Xstruct PERROR {
  1889. X    int errnum;                    /* Format of global error lookup */
  1890. X    char *errstr;
  1891. X};
  1892. X
  1893. Xstruct DPTR {                    /* Format of directory fetch pointer */
  1894. X    BPTR lock;                    /* lock on directory   */
  1895. X    FIB *fib;                    /* mod'd fib for entry */
  1896. X    };
  1897. X
  1898. Xextern struct HIST *H_head, *H_tail;
  1899. Xextern struct PERROR Perror[];
  1900. Xextern char **av;
  1901. Xextern char *Current;
  1902. Xextern int  H_len, H_tail_base, H_stack;
  1903. Xextern int  E_stack;
  1904. Xextern int  Src_stack, If_stack, forward_goto;
  1905. Xextern int  ac;
  1906. Xextern int  max_ac;
  1907. Xextern int  debug, Rval, Verbose, disable, Quit;
  1908. Xextern int  Lastresult, atoierr;
  1909. Xextern int  Exec_abortline;
  1910. Xextern int  S_histlen;
  1911. Xextern unsigned int options;
  1912. X
  1913. Xextern FILE *Src_base[MAXSRC];
  1914. Xextern long  Src_pos[MAXSRC];
  1915. Xextern short Src_if[MAXSRC], Src_abort[MAXSRC];
  1916. Xextern char  If_base[MAXIF];
  1917. Xextern struct Process *Myprocess;
  1918. Xextern struct CommandLineInterface *Mycli;
  1919. X
  1920. Xextern struct ArpBase *ArpBase;
  1921. X
  1922. Xextern char v_titlebar[], v_prompt[], v_hist[], v_histnum[], v_debug[],
  1923. X    v_verbose[], v_stat[], v_lasterr[], v_cwd[], v_except[], v_passed[],
  1924. X    v_path[], v_gotofwd[], v_linenum[], v_every[], v_lcd[], v_rxpath[],
  1925. X    v_hilite[], v_scroll[], v_minrows[], v_result[], v_qcd[], v_noreq[],
  1926. X    v_value[], v_nobreak[], v_bground[], v_pipe[], v_datefmt[], v_ioerr[],
  1927. X    v_abbrev[];
  1928. X
  1929. Xextern char o_hilite[], o_lolite[], *o_csh_qcd, o_internal;
  1930. Xextern char o_aux, o_minrows, o_scroll, o_nowindow, o_noraw, o_vt100;
  1931. Xextern char o_nofastscr, o_kick20, o_nobreak, o_bground, o_resident;
  1932. Xextern char o_pipe[], o_datefmt, o_abbrev;
  1933. Xextern long o_noreq;
  1934. Xextern char Buf[], isalph[], confirmed, *classfile;
  1935. X
  1936. Xextern char *MyMem;
  1937. X
  1938. X/* #define isalphanum(x) isalph[x] */
  1939. X
  1940. Xtypedef struct file_info {
  1941. X    LONG flags;
  1942. X    LONG size;
  1943. X    LONG blocks;
  1944. X    char class[12];
  1945. X    struct DateStamp date;
  1946. X} FILEINFO;
  1947. X
  1948. Xtypedef struct Class {
  1949. X    struct Class *next;
  1950. X    char name[1];
  1951. X} CLASS;
  1952. X
  1953. Xextern CLASS *CRoot, *LastCRoot;
  1954. Xextern struct Window *Win;
  1955. X
  1956. Xextern long IoError;
  1957. X
  1958. Xtypedef struct VNode {
  1959. X    struct VNode *next;
  1960. X    long len;
  1961. X    char *text;
  1962. X    char name[1];
  1963. X} NODE;
  1964. X
  1965. Xtypedef struct VRoot {
  1966. X    NODE         *first[MAXHASH];
  1967. X    struct VRoot *prev;
  1968. X} ROOT;
  1969. X
  1970. X
  1971. X#if 1
  1972. XLONG RunCommand( BPTR seg, long stack, UBYTE *paramptr, long paramlen );
  1973. Xstruct Segment *FindSegment( UBYTE *name, struct Segment *seg, long system );
  1974. XBOOL AssignAdd( UBYTE *name, BPTR lock );
  1975. X
  1976. X#ifdef AZTEC_C
  1977. X# pragma amicall(DOSBase, 0x1f8, RunCommand(d1,d2,d3,d4))
  1978. X# pragma amicall(DOSBase, 0x30c, FindSegment(d1,d2,d3))
  1979. X# pragma amicall(DOSBase, 0x276, AssignAdd(d1,d2))
  1980. X#else
  1981. X# pragma libcall DOSBase RunCommand 1f8 432104
  1982. X# pragma libcall DOSBase FindSegment 30c 32103
  1983. X# pragma libcall DOSBase AssignAdd 276 2102
  1984. X#endif
  1985. X
  1986. Xstruct RootNode2x {
  1987. X    BPTR    rn_TaskArray;
  1988. X    BPTR    rn_ConsoleSegment;
  1989. X    struct  DateStamp rn_Time;
  1990. X    LONG    rn_RestartSeg;
  1991. X    BPTR    rn_Info;
  1992. X    BPTR    rn_FileHandlerSegment;
  1993. X    struct MinList rn_CliList;
  1994. X    struct MsgPort *rn_BootProc;
  1995. X    BPTR    rn_ShellSegment;
  1996. X    LONG    rn_Flags;
  1997. X};
  1998. X
  1999. X
  2000. Xstruct DosList2x {
  2001. X    BPTR            dol_Next;
  2002. X    LONG            dol_Type;
  2003. X    struct MsgPort *dol_Task;
  2004. X    BPTR            dol_Lock;
  2005. X
  2006. X    union {
  2007. X        struct {
  2008. X            BSTR    dol_Handler;
  2009. X            LONG    dol_StackSize;
  2010. X            LONG    dol_Priority;
  2011. X            ULONG    dol_Startup;
  2012. X            BPTR    dol_SegList;
  2013. X            BPTR    dol_GlobVec;
  2014. X        } dol_handler;
  2015. X
  2016. X        struct {
  2017. X            struct DateStamp    dol_VolumeDate;
  2018. X            BPTR                dol_LockList;
  2019. X            LONG                dol_DiskType;
  2020. X        } dol_volume;
  2021. X
  2022. X        struct {
  2023. X            UBYTE     *dol_AssignName;
  2024. X            struct AssignList *dol_List;
  2025. X        } dol_assign;
  2026. X
  2027. X    } dol_misc;
  2028. X
  2029. X    BSTR    dol_Name;
  2030. X};
  2031. X
  2032. Xstruct AssignList2x {
  2033. X    struct AssignList *al_Next;
  2034. X    BPTR           al_Lock;
  2035. X};
  2036. X
  2037. X#define DLST_DEVICE     0
  2038. X#define DLST_DIRECTORY  1
  2039. X#define DLST_VOLUME     2
  2040. X#define DLST_LATE       3
  2041. X#define DLST_NONBINDING 4
  2042. X#define DLST_PRIVATE   -1
  2043. X
  2044. X#define ST_USERDIR      2
  2045. X#endif
  2046. END_OF_FILE
  2047. if test 6349 -ne `wc -c <'shell.h'`; then
  2048.     echo shar: \"'shell.h'\" unpacked with wrong size!
  2049. fi
  2050. # end of 'shell.h'
  2051. fi
  2052. if test -f 'technotes.doc' -a "${1}" != "-c" ; then 
  2053.   echo shar: Will not clobber existing file \"'technotes.doc'\"
  2054. else
  2055. echo shar: Extracting \"'technotes.doc'\" \(4227 characters\)
  2056. sed "s/^X//" >'technotes.doc' <<'END_OF_FILE'
  2057. X        TECHINCAL NOTES FOR CSHELL
  2058. X        ==========================
  2059. X
  2060. X
  2061. XTHE PARSER
  2062. X----------
  2063. X
  2064. XThe  heart  of  CShell  is the parser.  It was, I suppose, originally taken
  2065. Xfrom a UNIX csh. It does its job in two steps:
  2066. X
  2067. XFirst  comes  the  preformatting,  which is done while copying the original
  2068. Xline  to  a temporary buffer.  It is important to make a difference between
  2069. Xquoted  and  and  unquoted characters.  Earlier shell versions of the shell
  2070. Xset  the  most  significant  bit  of quoted chars, but this made the use of
  2071. Xinternational  character  sets  impossible.   Now  it's  done the other way
  2072. Xround:   Every _unquoted_ char with special meaning (e.g.  the asterisk) is
  2073. Xreplaced  by  a number between 128 and 159.  Ascii code 160 is used as word
  2074. Xseparator in strings (so words may contain blanks).
  2075. X
  2076. XAfter  the preformatting is done, the parser's main task is building up the
  2077. Xargument  array  av[i]  for  the internal and external commands.  Memory is
  2078. Xallocated  for  every argument and the argument is put together from one or
  2079. Xmore  tokens  (e.g.   $a$b).  After av[0] has been completed, certain flags
  2080. Xare  set  in  order  to  do  things  like preventing wild card expinsion of
  2081. Xarguments to 'dir'.
  2082. X
  2083. XThen,  with the argument line is complete, the aliases list is searched for
  2084. Xa  name that matches av[0].  If it exists, the parser is called recursively
  2085. Xwith  the  alias's  command line.  Recursive calls of the parser (using the
  2086. Xfunction  execute()) have no more side effects at all since version 5.1 and
  2087. Xcan therefore used to do things like automatic cd and class features.
  2088. X
  2089. XIn  order to speed up this process with many allocations and deallocations,
  2090. XI  have  written  a  custom  storage  allocator.   It  allocates  groups of
  2091. X1000-byte-blocks  (called  frames)  using malloc() and then distibutes them
  2092. Xuntil  they're  used  up.  Of course, deallocation of single allocations is
  2093. Xnot  possible,  only  the  frame as a whole can be deallocated.  But that's
  2094. Xokay, since all temporaries are deallocated when the parser is left.
  2095. X
  2096. X
  2097. XTHE BUILTINS
  2098. X------------
  2099. X
  2100. XThe other side of the shell are the built in commands.  They look much like
  2101. XCLI commands in C, but they have lots of support functions for their needs.
  2102. X
  2103. XTo  write a builtin command for CShell, you use the global variables av and
  2104. Xac  instead of argv and argc, and use printf() for output.  That's it.  Any
  2105. Xother changes, if necessary, will be done by me.
  2106. X
  2107. XEvery  builtin  command  has its equivalent as a C function with the prefix
  2108. Xdo_ (example:  do_addbuffers).  The are no hard coded jumps to any of those
  2109. Xfunctions,  instead there is a table with the descriptions of all functions
  2110. X(like  name, usage, minimum arguments and, last but not least, a pointer to
  2111. Xthat function).
  2112. X
  2113. X
  2114. XWHY BUILT IN COMMANDS?
  2115. X----------------------
  2116. X
  2117. XThe reasons why C-Shell still relies heavily on internal commands:
  2118. X- They can take advantage from each other (e.g. class recognition in the
  2119. X  'dir' command, use of 'search' command in quick cd)
  2120. X- They have a fast calling sequence
  2121. X- They need no hard disk seeks, so the startup can be accelerated
  2122. X  significantly
  2123. X- They are shorter than external commands
  2124. X- And finally, if you don't like them, don't use them. The wasted resources
  2125. X  become more and more negligible nowadays... CShell uses 2% of my memory.
  2126. X
  2127. X
  2128. XSOURCES
  2129. X-------
  2130. X
  2131. XThe  source  for CShell is available, if you don't have it, request it from
  2132. Xme.   It consists of 10 modules, together 200K.  It is compilable under SAS
  2133. X(Lattice)  &  Manx  C,  although  the  executables produced by Manx are not
  2134. Xresidentable.   If you want to modify it, ask me for an up-to-date version
  2135. Xfirst.   You  may  not  release  modified  versions  (imagine  the chaos if
  2136. Xeverbody  releases his private csh), but if you send them to me, you have a
  2137. Xgood  chance  that I'll build it in.  You'll be, of course, be mentioned in
  2138. Xthe docs.
  2139. X
  2140. XEven  if  you  don't  intend to modify it, I still encourage you to get the
  2141. Xsource,  because  there  are  so many things you can look up there once you
  2142. Xneed them (did *you* know how to set the system date?).  I apologize for my
  2143. Xpoor to nonexistent comments, I'll go through again when I've got the time.
  2144. XAh,  yes,  that  famous  Dillon-formatting  is gone, now it's traditionally
  2145. Xformatted.
  2146. END_OF_FILE
  2147. if test 4227 -ne `wc -c <'technotes.doc'`; then
  2148.     echo shar: \"'technotes.doc'\" unpacked with wrong size!
  2149. fi
  2150. # end of 'technotes.doc'
  2151. fi
  2152. if test -f 'tips.doc' -a "${1}" != "-c" ; then 
  2153.   echo shar: Will not clobber existing file \"'tips.doc'\"
  2154. else
  2155. echo shar: Extracting \"'tips.doc'\" \(3454 characters\)
  2156. sed "s/^X//" >'tips.doc' <<'END_OF_FILE'
  2157. XSome good ideas:
  2158. X
  2159. X
  2160. X    EDITING
  2161. X
  2162. X
  2163. XThe very common situation:
  2164. X$ mkdir documents
  2165. X$ cd documents
  2166. Xcan be abbreviated to:
  2167. X$ mk documents
  2168. X$ [CTRL-T]              (inserts all but first word of previous line)
  2169. X
  2170. X
  2171. XAlso very common:
  2172. X$ mv document document1
  2173. X$ mv document[CTRL-P]1
  2174. XThe CTRL-P function duplicates the previous word on the command line
  2175. X
  2176. X
  2177. XYou  might  have  wondered  what  CTRL-N  (leave current line) is good for.
  2178. XAssume, for example, you just typed
  2179. X$ rm dh1:graphics/lo-res/gorilla
  2180. Xwhen  it comes to your mind that would prefer to keep a copy of that pic on
  2181. Xdiskette.  Many would now delete this command line.  Being a smart guy, you
  2182. Xdo the following:
  2183. X$ [CTRL-N]              (leaves this command line alone)
  2184. X$ co[CTRL-T] df0:
  2185. X$ [Up-Arrow][Up-Arrow]  (gets back the command line you left)
  2186. X
  2187. X
  2188. XIn case you don't know what history completion is:
  2189. X$ search *.c *.h makefile foobar
  2190. X$ ram:
  2191. X$ dir
  2192. X$ rm tmpfile
  2193. XNow if want to repeat the search command, enter
  2194. X$ se[Shift-Up-Arrow]
  2195. Xwhich brings up the the last command that started with 'se'.
  2196. X
  2197. X
  2198. XIf you want to delete the file
  2199. X$ dh2:comm/uucp/mail/junk/409
  2200. Xand you're far away from that directory, enter
  2201. X$ ju[ESC-c]409          (enters the result of cd ju)
  2202. X
  2203. X
  2204. XThe  same function is also usable for 'cd'.  Assume you have several 'junk'
  2205. Xdirectories:
  2206. X$ ju[ESC-c][CTRL-R][CTRL-R][CTRL-R]
  2207. XLike  this  you'll cycke through the junk directories.  When you've got the
  2208. Xright one, press enter.
  2209. X
  2210. X
  2211. XAssume  there  are the files comm1.c, comm2.c, and comm3.c as well as their
  2212. Xcorresponding .o files.  You want comm3.c:
  2213. X$ co[Shift-Tab]1[Tab]
  2214. XOf course this is more useful with longer file names.
  2215. X
  2216. X
  2217. XYou can tab file name expand any patterns, not only abbreviations.  Assume
  2218. Xyou want to delete all .c files in the current directory but the last:
  2219. X$ rm *.c[ESC-Tab][CTRL-W]
  2220. XIn addition, you get to see all the files once again before deleting them.
  2221. X
  2222. X
  2223. XNext one: You have entered:
  2224. X$ dir
  2225. X$ foreach i ( *.c ) "e >>ram:temp $i
  2226. X$ more ram:temp
  2227. Xand you would like to execute the same three statements again, enter:
  2228. X$ [Up-Arrow][Up-Arrow][Up-Arrow][ESC-Return][CTRL-R][CTRL-R]
  2229. X
  2230. X
  2231. XI  know  that  the editing is not very user friendly.  This is because it's
  2232. Xquite  hard  and troublesome to get raw keycodes from the console, and it's
  2233. Ximpossible  to  get  them  from a VT200 terminal.  Therefore I had to stick
  2234. Xwith CTRL and ESC combinations. Once you have learnt them (some of them are
  2235. Xsimilar to EMACS), you can save lots of typing.
  2236. X
  2237. X
  2238. X    COMMANDS
  2239. X
  2240. X
  2241. XMy  advice  here  is clear:  Use aliases, aliases, aliases.  In order to be
  2242. Xable  to  create  them as quickly as possible, create an alias (e.g.  'le')
  2243. Xthat edits your login file, plus another one (e.g.  'lx'), that re-executes
  2244. Xit.   My  login  contains  almost  only aliases, everthing else I've put in
  2245. X'firstlogin.sh'.
  2246. X
  2247. X
  2248. XIf you don't like the default options of one command, you can add more of
  2249. Xthem using an alias:
  2250. X$ alias dir "dir -q
  2251. XFrom now on, blocks will no longer be displayed in 'dir'.
  2252. X
  2253. X
  2254. XIf your aliases have arguments, e.g.
  2255. X$ alias sc "search *.c
  2256. Xproblems arise when you try to specify options. e.g. case sensitivity:
  2257. X$ sc -c "hello world
  2258. Xthis will obviously not work. That's what @pickopts is good for:
  2259. X$ alias sc "%a search @pickopts( $a ) *.c @pickargs( $a )
  2260. X
  2261. X
  2262. XOnce you have more aliases, it is useful to keep them sorted.  You might
  2263. Xalso document them: Create a file 'aliases.doc', and perform
  2264. X$ set _man aliases.doc csh.doc
  2265. XThat way, you can document them in a separate file.
  2266. X
  2267. X
  2268. END_OF_FILE
  2269. if test 3454 -ne `wc -c <'tips.doc'`; then
  2270.     echo shar: \"'tips.doc'\" unpacked with wrong size!
  2271. fi
  2272. # end of 'tips.doc'
  2273. fi
  2274. echo shar: End of archive 1 \(of 6\).
  2275. cp /dev/null ark1isdone
  2276. MISSING=""
  2277. for I in 1 2 3 4 5 6 ; do
  2278.     if test ! -f ark${I}isdone ; then
  2279.     MISSING="${MISSING} ${I}"
  2280.     fi
  2281. done
  2282. if test "${MISSING}" = "" ; then
  2283.     echo You have unpacked all 6 archives.
  2284.     rm -f ark[1-9]isdone
  2285. else
  2286.     echo You still need to unpack the following archives:
  2287.     echo "        " ${MISSING}
  2288. fi
  2289. ##  End of shell archive.
  2290. exit 0
  2291. -- 
  2292. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  2293. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  2294. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  2295.